import { useParams } from "react-router-dom";
function List({ data, allData, limit }) {
    let { type = "all", page = "1" } = useParams();
    page = Number(page);
    // console.log(typeof(page))
    let start = (page - 1) * limit;
    let end = start + limit;
    let nowData = allData.filter((item, index) => (index >= start && index < end));
    let nowLen = Math.ceil(allData.length / limit)
    if (type !== "all") {
        nowData = data[type].filter((item, index) => (index >= start && index < end))
        nowLen = Math.ceil(data[type].length / limit)
    }
    // console.log(nowLen)
    return (
        <ul className="list">
            {page <= nowLen ? nowData.map(item => <li key={item.id}> {item.id}-{item.title} </li>) : <p>没有更多数据了</p>}
        </ul>
    )
}

export default List